(async function () {
    
  const createdTodos = await api.runAsyncOnBackendWithManualTransactionHandling(async () => {
    
     const calendarTemplate =(api.getNoteWithLabel("calendarTemplates").getChildNotes()
      ).find((m) => m.hasAttribute("label", "calendarNote"));
      
    
    
    const renderNote = api.getNoteWithLabel("CalendarRenderNote");
    const todos = await api.getNotesWithLabel("initCalendarRoot");
    for await (const todo of todos) {        
    todo.addLabel("calendarNotes");
    todo.addRelation("child:template", calendarTemplate.noteId);
    todo.addRelation("renderNote", renderNote.noteId);
    todo.removeLabel("initCalendarRoot"); 
    todo.type = "render";
    todo.mime = "";
    todo.save();
    }  
    
    return todos.length;
  });
  await api.waitUntilSynced();

  if (createdTodos) {
    api.showMessage(`${createdTodos} created! Good session!`);
  }
})();